<?php
namespace Home\Controller;
use Think\Controller;
class IndexController extends Controller {

    public function exec(){
    	// URL_PATHINFO_DEPR 分割符有bug，
    	$cals = strstr(__INFO__, '~cals~');
    	$cals = ltrim($cals, '~cals~');
    	// $cals = I('get.cals');
		$has_opt = false;
		if(fasle !== stripos($cals, '+')){
			$has_opt = true;
		}elseif(fasle !== stripos($cals, '-')){
			$has_opt = true;
		}elseif(fasle !== stripos($cals, '*')){
			$has_opt = true;
		}elseif(fasle !== stripos($cals, '/')){
			$has_opt = true;
		}

		try {
			$result = eval("return $cals ;");
			$this->show("'{$cals}' 的计算结果为：{$result}。");
		} catch (Exception $e) {
			$this->show('公式计算错误：'.$cals.'请检查后重新输入计算式：');
		}
	}
}